package com.weixin.paleituo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.weixin.paleituo.R;
import com.weixin.paleituo.util.UIUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Author yichao
 * Time  2017/12/1 0:38
 * Dest  发布管理
 */

public class ReleasemanagerRecyclerViewAdapter extends RecyclerView.Adapter<ReleasemanagerRecyclerViewAdapter.ViewHolder> {


    private Context mContext;

    public ReleasemanagerRecyclerViewAdapter(Context context) {
        mContext = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = UIUtils.inflate(mContext, R.layout.item_release_manager, parent, false);

        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position) {

        if (mOnItemClickListener != null) {
            holder.mLlRootLayoutItemFloorHome.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mOnItemClickListener.onClick(v, position);
                }
            });
            holder.mTvDelecte.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mOnItemClickListener.onDelectClick(v,position);
                }
            });


        }
    }

    @Override
    public int getItemCount() {
        return 2;
    }

    static

    public class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.ll_root_item_release_manager)
        LinearLayout mLlRootLayoutItemFloorHome;
        @BindView(R.id.tv_delect_item_release_manager)
        TextView mTvDelecte;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

    private OnItemClickListener mOnItemClickListener;

    public interface OnItemClickListener {
        /**点击条目*/
        public void onClick(View v, int position);
        /**点击删除*/
        public void  onDelectClick(View v,int position);

    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.mOnItemClickListener = onItemClickListener;

    }


}
